import purchase from './routesModal/routes-purchase'
import supplier from './routesModal/routes-supplier'
import storage from './routesModal/routes-storage'
import carMessage from './routesModal/routes-carMessage'
import workflow from './routesModal/routes-workflow'
import system from './routesModal/routes-system'
import tool from './routesModal/routes-tool'
import customer from './routesModal/routes-customer-center'
import user from './routesModal/routes-user'
import systemSetup from './routesModal/routes-systemSetup'
import merchantCenter from './routesModal/routes-merchantCenter'
import order from './routesModal/routes-order'
import finance from './routesModal/routes-finance'

export interface RouteItem {
	menuname: Array<string>
	asdefault?: boolean // 默认显示
	path?: string
	type?: boolean
	component?: string | (() => any)
	isTabMenu?: boolean
	tabTitle?: string
	permission?: string
}

export type RoutesConfig = RouteItem[]
const config: RoutesConfig = [
	// 首页路由
	{
		menuname: ['首页'],
		asdefault: true,
		path: '/',
		component: '../pages/user',
	},
	// 个人中心
	...user,
	// 供应商管理
	...supplier,
	// 采购管理
	...purchase,
	// 仓储管理
	...storage,
	// 车辆管理
	...carMessage,
	// 工作流管理
	...workflow,
	// 管理工具
	...tool,
	// 系统设置
	...system,
	// 系统设置
	...systemSetup,
	// 客户中心
	...customer,
	// 营销中心
	...merchantCenter,
	// 订单管理
	...order,
	// 财务管理
	...finance,
]

/**
 * @description: 生成umi路由配置
 * @param {?RoutesConfig} routesConfig
 * @return {} umi路由配置
 */
export function generateRoutes(routesConfig: RoutesConfig = config) {
	return routesConfig.map((item) => ({
		path: item.path,
		component: item.component,
	}))
}

export default config
